package main.test.meituan;


import java.util.Scanner;
import java.util.Stack;

public class T2 {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        if (n==0){
            System.out.println(0);
            return;
        }
        String s=sc.nextLine();
        char[] chars = s.toCharArray();
        Stack<Character> stack=new Stack<>();
        int min=0;
        int max=0;
        for (int i = 0; i < chars.length-1; i++) {
            if (chars[i]!=chars[chars.length-i-1]){
                continue;
            }else if (stack.isEmpty()){
                if (min==0){
                    min=i;
                }else {
                    max=i;
                }
            }else {
                stack.pop();
            }
        }
        if (max==0){
            System.out.println(n-stack.size());
        }else{
            System.out.println(n-(max-min+1));
        }
    }
}
